package com.jksoft.meteo.data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.jksoft.meteo.util.WindDirection;

public class WeatherForecast implements Serializable {

	private static final long serialVersionUID = 1L;

	private List<WeatherEntry> forecast;

	private String condition;
	private String humidity;
	private String iconURL;
	private String temperature;
	private String wind;

	public WeatherForecast() {
		forecast = new ArrayList<WeatherEntry>();
	}

	public WeatherForecast(String humidity, String temperature, String condition) {
		this.humidity = humidity;
		this.temperature = temperature;
		this.condition = condition;

		forecast = new ArrayList<WeatherEntry>();
	}

	public void addForecastEntry(WeatherEntry entry) {
		if (entry != null)
			forecast.add(entry);
	}

	public String getCondition() {
		return condition;
	}

	public List<WeatherEntry> getForecast() {
		return forecast;
	}

	public String getHumidity() {
		return humidity;
	}
	
	public String getIconURL() {
		return iconURL;
	}

	public String getTemperature() {
		return temperature;
	}

	public String getWind() {
		return wind;
	}

	public void setCondition(String condition) {
		this.condition = condition;
	}

	public void setForecast(List<WeatherEntry> forecast) {
		if (forecast != null)
			this.forecast = forecast;
	}

	public void setHumidity(String humidity) {
		this.humidity = humidity;
	}
	
	public void setIconURL(String iconURL) {
		this.iconURL = iconURL;
	}

	public void setTemperature(String temperature) {
		this.temperature = temperature;
	}

	public void setWind(String wind) {
		this.wind = convertWindInformation(wind).getCode();
	}

	public void setWind(WindDirection windDirection) {
		this.wind = windDirection.getCode();
	}

	private static WindDirection convertWindInformation(int degrees) {
		return WindDirection.getDirection(degrees);
	}

	private static WindDirection convertWindInformation(String degrees) {
		return convertWindInformation(Integer.parseInt(degrees));
	}
}
